/**
 * request logic
 */
const NET_CODE_SUC = 200;

/**
  * 判断服务请求是否成功
  * @param response
  * @returns {*|boolean}
  */
export function isResponseSuccess (response) {
  return response && response.code && response.code === NET_CODE_SUC;
}
/**
 * 询价需求 inquiry
*/
// 需求状态 待受理 待询价 已取消
export const DEMAND_PENDING_STATUS_CODE = 10;
export const DEMAND_PENDING_STATUS_DES = '待受理';
export const DEMAND_INQURIY_STATUS_CODE = 20;
export const DEMAND_INQURIY_STATUS_DES = '已受理';
export const DEMAND_INQURIY_IN_STATUS_CODE = 25;
export const DEMAND_INQURIY_IN_STATUS_DES = '询价中';
export const DEMAND_INQURIY_FINSH_STATUS_CODE = 40;
export const DEMAND_INQURIY_FINSH_STATUS_DES = '已完成';
export const DEMAND_INQURIY_NO_STATUS_CODE = 30;
export const DEMAND_INQURIY_NO_STATUS_DES = '询价异常';
export const DEMAND_CANCELLED_STATUS_CODE = 15;
export const DEMAND_CANCELLED_STATUS_DES = '询价取消';

// 完成状态 已完成 未完成
export const COMPLETED_STATUS_CODE = 10;
export const COMPLETED_STATUS_DES = '已完成';
export const COMPLETED_NO_STATUS_DES = '未完成';

// 询价需求---订货---筛选区域 --商品订货状态
export const COMMODITY_ORDER_STATUS_NO_CODE = 10
export const COMMODITY_ORDER_STATUS_NO_DES = '待受理'
export const COMMODITY_ORDER_STATUS_YES_CODE = 20
export const COMMODITY_ORDER_STATUS_YES_DES = '已受理'
export const COMMODITY_ORDER_STATUS_IN_CODE = 30
export const COMMODITY_ORDER_STATUS_IN_DES = '询价中'
export const COMMODITY_ORDER_STATUS_OK_CODE = 40
export const COMMODITY_ORDER_STATUS_OK_DES = '已完成'
export const COMMODITY_ORDER_STATUS_NOMAL_CODE = 50
export const COMMODITY_ORDER_STATUS_NOMAL_DES = '订货异常'
export const COMMODITY_ORDER_STATUS_CLEAR_CODE = 60
export const COMMODITY_ORDER_STATUS_CLEAR_DES = '订货取消'
export const COMMODITY_ORDER_STATUS_TO_PRICED_CODE = 70
export const COMMODITY_ORDER_STATUS_TO_PRICED_DES = '待二次定价'
export const COMMODITY_ORDER_STATUS = [
  { id: COMMODITY_ORDER_STATUS_NO_CODE, name: COMMODITY_ORDER_STATUS_NO_DES },
  { id: COMMODITY_ORDER_STATUS_YES_CODE, name: COMMODITY_ORDER_STATUS_YES_DES },
  { id: COMMODITY_ORDER_STATUS_IN_CODE, name: COMMODITY_ORDER_STATUS_IN_DES },
  { id: COMMODITY_ORDER_STATUS_OK_CODE, name: COMMODITY_ORDER_STATUS_OK_DES },
  { id: COMMODITY_ORDER_STATUS_NOMAL_CODE, name: COMMODITY_ORDER_STATUS_NOMAL_DES },
  { id: COMMODITY_ORDER_STATUS_CLEAR_CODE, name: COMMODITY_ORDER_STATUS_CLEAR_DES },
  { id: COMMODITY_ORDER_STATUS_TO_PRICED_CODE, name: COMMODITY_ORDER_STATUS_TO_PRICED_DES }
]
export const COMMODITY_ORDER_OK_STATUS = [
  { id: COMMODITY_ORDER_STATUS_OK_CODE, name: COMMODITY_ORDER_STATUS_OK_DES },
  { id: COMMODITY_ORDER_STATUS_TO_PRICED_CODE, name: COMMODITY_ORDER_STATUS_TO_PRICED_DES }
]
// 询价需求---订货---筛选区域 --订货类型
export const ORDER_TYPE_DIRECT_CODE = 1
export const ORDER_TYPE_DIRECT_DES = '直接订货'
export const ORDER_TYPE_INQUIRY_CODE = 2
export const ORDER_TYPE_INQUIRY_DES = '询价单订货'
export const ORDER_TYPE = [
  { id: ORDER_TYPE_DIRECT_CODE, name: ORDER_TYPE_DIRECT_DES },
  { id: ORDER_TYPE_INQUIRY_CODE, name: ORDER_TYPE_INQUIRY_DES },
]
// 询价需求 --- 筛选区域----需求状态
export const DEMAND_QUOTED_PRICE_STATUS_CODE = 40;
export const DEMAND_QUOTED_PRICE_STATUS_DES = '已采购报价';
export const DEMAND_QUOTED_SOLD_STATUS_CODE = 50;
export const DEMAND_QUOTED_SOLD_STATUS_DES = '销售已定价';
export const DEMAND_STATUS_IN = [
  { id: DEMAND_QUOTED_PRICE_STATUS_CODE, name: DEMAND_QUOTED_PRICE_STATUS_DES },
  { id: DEMAND_QUOTED_SOLD_STATUS_CODE, name: DEMAND_QUOTED_SOLD_STATUS_DES },
]
export const DEMAND_INQURIY = [
  { id: DEMAND_PENDING_STATUS_CODE, name: DEMAND_PENDING_STATUS_DES },
  { id: DEMAND_INQURIY_STATUS_CODE, name: DEMAND_INQURIY_STATUS_DES },
  { id: DEMAND_INQURIY_IN_STATUS_CODE, name: DEMAND_INQURIY_IN_STATUS_DES },
  { id: DEMAND_INQURIY_NO_STATUS_CODE, name: DEMAND_INQURIY_NO_STATUS_DES },
  { id: DEMAND_CANCELLED_STATUS_CODE, name: DEMAND_CANCELLED_STATUS_DES },
  { id: DEMAND_QUOTED_PRICE_STATUS_CODE, name: DEMAND_QUOTED_PRICE_STATUS_DES },
  { id: DEMAND_QUOTED_SOLD_STATUS_CODE, name: DEMAND_QUOTED_SOLD_STATUS_DES },
]
// 异常原因 --- 询价异常原因字典
export const ABNORMAL_INQUIRY_NORMAL_GOOD_CODE = 18968
export const ABNORMAL_INQUIRY_NORMAL_GOOD_DES = '正常商品'
export const ABNORMAL_INQUIRY_NORMAL_SALSENO_CODE = 40392
export const ABNORMAL_INQUIRY_NORMAL_SALSENO_DES = '销售通知取消'
export const ABNORMAL_INQUIRY_NORMAL_CDITYINFION_CODE = 40393
export const ABNORMAL_INQUIRY_NORMAL_CDITYINFION_DES = '商品信息不全'
export const ABNORMAL_INQUIRY_NORMAL_REPTINQUY_CODE = 40394
export const ABNORMAL_INQUIRY_NORMAL_REPTINQUY_DES = '询价重复'
export const ABNORMAL_INQUIRY_NORMAL_MAREK_CODE = 40395
export const ABNORMAL_INQUIRY_NORMAL_MAREK_DES = '市场/厂家无此规格'
export const ABNORMAL_INQUIRY_NORMAL_NOCHANNEL_CODE = 40396
export const ABNORMAL_INQUIRY_NORMAL_NOCHANNEL_DES = '无渠道'
export const ABNORMAL_INQUIRY_NORMAL_KEEP_CODE = 40397
export const ABNORMAL_INQUIRY_NORMAL_KEEP_DES = '备案时间长暂不报价'
export const ABNORMAL_INQUIRY_NORMAL_HASBEEN_CODE = 40398
export const ABNORMAL_INQUIRY_NORMAL_HASBEEN_DES = '已被其它经销商备案'
export const ABNORMAL_INQUIRY_NORMAL_NOSHORT_CODE = 40399
export const ABNORMAL_INQUIRY_NORMAL_NOSHORT_DES = '未达到厂家最小起订量'
export const ABNORMAL_INQUIRY_NORMAL_APPOINT_CODE = 40400
export const ABNORMAL_INQUIRY_NORMAL_APPOINT_DES = '指定品牌已不生产'
export const ABNORMAL_INQUIRY_NORMAL_OTHER_CODE = 40401
export const ABNORMAL_INQUIRY_NORMAL_OTHER_DES = '其它'
// 异常原因 --- 订货异常原因字典
export const ABNORMAL_ORDER_NORMAL_SALSENO_CODE = 40402
export const ABNORMAL_ORDER_NORMAL_REPTINQUY_CODE = 40403
export const ABNORMAL_ORDER_NORMAL_REPTINQUY_DES = '订货重复'
export const ABNORMAL_ORDER_NORMAL_KEEP_CODE = 40404
export const ABNORMAL_ORDER_NORMAL_KEEP_DES = '备案时间长暂不能订货'
export const ABNORMAL_ORDER_NORMAL_HASBEEN_CODE = 40405
export const ABNORMAL_ORDER_NORMAL_NOSHORT_CODE = 40406
export const ABNORMAL_ORDER_NORMAL_APPOINT_CODE = 40407
export const ABNORMAL_ORDER_NORMAL_NO_CODE = 40408
export const ABNORMAL_INQUIRY_NO_OTHER_DES = '厂家无货'
export const ABNORMAL_ORDER_NORMAL_OTHER_CODE = 40409

export const ABNORMAL_CAUSE_INQUIRY = [
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_GOOD_CODE, reason: ABNORMAL_INQUIRY_NORMAL_GOOD_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_SALSENO_CODE, reason: ABNORMAL_INQUIRY_NORMAL_SALSENO_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_CDITYINFION_CODE, reason: ABNORMAL_INQUIRY_NORMAL_CDITYINFION_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_REPTINQUY_CODE, reason: ABNORMAL_INQUIRY_NORMAL_REPTINQUY_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_MAREK_CODE, reason: ABNORMAL_INQUIRY_NORMAL_MAREK_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_NOCHANNEL_CODE, reason: ABNORMAL_INQUIRY_NORMAL_NOCHANNEL_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_KEEP_CODE, reason: ABNORMAL_INQUIRY_NORMAL_KEEP_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_HASBEEN_CODE, reason: ABNORMAL_INQUIRY_NORMAL_HASBEEN_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_NOSHORT_CODE, reason: ABNORMAL_INQUIRY_NORMAL_NOSHORT_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_APPOINT_CODE, reason: ABNORMAL_INQUIRY_NORMAL_APPOINT_DES },
  { expReasonId: ABNORMAL_INQUIRY_NORMAL_OTHER_CODE, reason: ABNORMAL_INQUIRY_NORMAL_OTHER_DES }
]
export const ABNORMAL_CAUSE_ORDER = [
  { expReasonId: ABNORMAL_ORDER_NORMAL_SALSENO_CODE, reason: ABNORMAL_INQUIRY_NORMAL_SALSENO_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_REPTINQUY_CODE, reason: ABNORMAL_ORDER_NORMAL_REPTINQUY_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_KEEP_CODE, reason: ABNORMAL_ORDER_NORMAL_KEEP_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_HASBEEN_CODE, reason: ABNORMAL_INQUIRY_NORMAL_HASBEEN_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_NOSHORT_CODE, reason: ABNORMAL_INQUIRY_NORMAL_NOSHORT_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_APPOINT_CODE, reason: ABNORMAL_INQUIRY_NORMAL_APPOINT_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_NO_CODE, reason: ABNORMAL_INQUIRY_NO_OTHER_DES },
  { expReasonId: ABNORMAL_ORDER_NORMAL_OTHER_CODE, reason: ABNORMAL_INQUIRY_NORMAL_OTHER_DES },
]
export const gettimefn = item => {
  let gettime = '';
  let yy = new Date().getFullYear();
  let mm = new Date().getMonth() + 1;
  let dd = new Date().getDate();
  let hh = new Date().getHours();
  let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
  let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
  gettime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
  return gettime
}
// 完成状态
export const formatCompletedStatus = item => {
  return item == COMPLETED_STATUS_CODE
    ? COMPLETED_STATUS_DES
    : COMPLETED_NO_STATUS_DES;
}

// 关联需求信息
export const DEMAND_COLUMNS = [
  /* {
    key: 'serNum',
    title: '序号',
    width: 50,
  }, */
  {
    key: 'inquiryEntryId',
    title: '需求ID',
  },
  {
    key: 'skuName',
    title: '需求名称',
  },
  {
    key: 'normalSkuCode',
    title: '正常商品代码',
  },
  {
    key: 'normalSkuName',
    title: '正常商品名称',
  },
  {
    key: 'supplierCode',
    title: '供应商代码',
  },
  {
    key: 'supplierName',
    title: '供应商名称',
  },
  {
    key: 'costPrice',
    title: '成本价',
  },
  {
    key: 'action',
    title: '操作',
  },
]
